package com.ruoyi.system;

import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.RandomNameGenerator;
import com.ruoyi.system.service.UserService;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@RunWith(SpringRunner.class)
@SpringBootTest
public class test1 {

    @Resource
    UserService userService;

    @Resource
    ISysUserService iSysUserService;


    //添加
    @Test
    public void test2() throws InterruptedException {
        userService.addUsers(10000);
    }

    //列表
    @Test
    public void test3() {
        SysUser user = new SysUser();
        List<SysUser> sysUsers = iSysUserService.selectUserList(user);
        for (SysUser sysUser : sysUsers) {
            System.out.println(sysUser);
        }
    }

    //修改
    @Test
    public void test4() {
        SysUser user = new SysUser();
        int i = iSysUserService.updateUser(user);
        System.out.println(i);
    }

    //删除
    @Test
    public void test5() {
        Long id = Long.valueOf(1);
        int i = iSysUserService.deleteUserById(id);
        System.out.println(i);
    }

    //添加
    @Test
    public void test6() {
        SysUser user = new SysUser();
        user.setUserName("user5");
        user.setPassword("$10$uVOv5iXqq2NRyu0epTmn5OA6zbKMNbgUfu6dnNHPTy0NB9CNeRM2u");
        user.setNickName("程序员的浪漫");
        user.setEmail("123@qq.com");
        user.setRemark("普通用户");
        user.setAddress("山西");
        user.setAge(12);
        int i = iSysUserService.insertUser(user);
        System.out.println(i);
    }

    //生成随机名称
    @Test
    public void test7() {
        RandomNameGenerator generator = new RandomNameGenerator();
        generator.generateNames(10);
        Set<String> generatedNames = generator.getGeneratedNames();
        for (String generatedName : generatedNames) {
            System.out.println(generatedName);
        }
    }

}
